package com.hx.sqliteHelper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class SQLliteHelper extends SQLiteOpenHelper{

	//1.定义常量
	private static final String DATABASE_NAME="diary_db";
	private static final String TABLE_NAME="diary";
	private static final int VERSION=1;
	
	//2.重写构造函数
	public SQLliteHelper(Context context){
		super(context,DATABASE_NAME,null,VERSION);
	}
	 /*
	  * context 上下文环境，activtity运行环境
	  * name 数据库表名
	  * factory 接收数据，一般full
	  * version 版本号
	  */
	public SQLliteHelper(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
	}

	//3.数据表创建
	@Override
	public void onCreate(SQLiteDatabase db) {
		String sql="create table "+TABLE_NAME+"(tid integer primary key autoincrement,title varchar(100),weather varchar(10), context text,publish date)";
		db.execSQL(sql);
		System.out.println("创建表。。。。。。。。。。。。。。。");
		
	}
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}

}
